from paste.errordocument import StatusBasedForward
from paste.recursive import RecursiveMiddleware
from urllib import urlencode

def error_mapper(code, message, environ, global_conf, kw)
    if code in [404, 500]:
        #params = urlencode({'message':message, 'code':code})
        url = '/@@mambo-baad?'%(params)
        return url
    else:
        return None

app = RecursiveMiddleware(
    StatusBasedForward(app, mapper=error_mapper),
)
